﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Configuration;
using MongoDb.EntityFramework;
using StructureMap;

namespace SManagement.Models
{
    internal static class Setup
    {
        public static void Initialize()
        {
            // Initialize our concrete database provider type.
            ObjectFactory.Initialize(x =>
            {
                x.For<IRepository>().Use(new MongoRepository(WebConfigurationManager.ConnectionStrings["mongoManagementConnection"].ConnectionString));
            });
        }

        /// <summary>
        /// Disposes the database provider context.
        /// </summary>
        public static void Close()
        {
            if (MongoDbContext.IsOpen)
            {
                MongoDbContext.Current.Dispose();
            }
        }
    }
}